package org.jiuling.appletofwechat.model;

import org.jiuling.local.tools.enums.IDDAreaCodeEnum;

import java.util.Date;

/**
 * 电话信息模型
 * @author 紫灵
 * @date 2024年01月29日 12时39分04秒
 */
public class PhoneInfoModel {

    /** 用户绑定的手机号（国外手机号会有区号） */
    private String phoneNumber;
    /** 没有区号的手机号 */
    private String purePhoneNumber;
    /** 区号 */
    private IDDAreaCodeEnum iddAreaCode;
    /** 数据水印 */
    private WatermarkModel watermark;

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public String getPurePhoneNumber() {
        return purePhoneNumber;
    }

    public IDDAreaCodeEnum getIddAreaCode() {
        return iddAreaCode;
    }

    public WatermarkModel getWatermark() {
        return watermark;
    }

    /**
     * 数据水印
     */
    public static class WatermarkModel{
        private Date timeStamp;
        private String appId;

        public Date getTimeStamp() {
            return timeStamp;
        }

        public String getAppId() {
            return appId;
        }

        public static Builder builder(){
            return new Builder();
        }

        public static final class Builder{
            private final WatermarkModel watermark;

            public Builder() {
                this.watermark = new WatermarkModel();
            }

            public Builder addTimeStamp(long timeStamp){
                watermark.timeStamp = new Date(timeStamp);
                return this;
            }

            public Builder addAppId(String appId){
                watermark.appId = appId;
                return this;
            }

            public WatermarkModel build(){
                return this.watermark;
            }
        }
    }

    public static Builder builder(){
        return new Builder();
    }

    public static final class Builder {

        private final PhoneInfoModel phoneInfoModel;
        private Builder() {
            this.phoneInfoModel = new PhoneInfoModel();
        }

        public Builder addPhoneNumber(String phoneNumber) {
            phoneInfoModel.phoneNumber = phoneNumber;
            return this;
        }

        public Builder addPurePhoneNumber(String purePhoneNumber) {
            phoneInfoModel.purePhoneNumber = purePhoneNumber;
            return this;
        }

        public Builder addIddAreaCode(IDDAreaCodeEnum iddAreaCode) {
            phoneInfoModel.iddAreaCode = iddAreaCode;
            return this;
        }

        public Builder addWatermark(WatermarkModel watermark) {
            phoneInfoModel.watermark = watermark;
            return this;
        }

        public PhoneInfoModel build() {
            return this.phoneInfoModel;
        }
    }
}
